#include "accepter.h"

#include "netlib.h"

namespace kxlua {

Accepter::Accepter(NetLib* lib) {
    lib_ = lib;
    name_ = "Accepter";
    isOpen_ = false;
}

Accepter::~Accepter() {
}

const std::string& Accepter::GetName() const {
    return name_;
}

bool Accepter::Open() {
    if (!isOpen_) {
        luabind::module(lib_->GetLua().GetState()) 
        [
            luabind::def("CreateAccepter", &net::GetAccepter),

            luabind::class_<net::IAccepter>("Accepter")
            .def("Close", &net::IAccepter::Close)
            .def("Listen", &net::IAccepter::Listen)
            .def("SetHandler", &net::IAccepter::SetHandler)
        ];
        isOpen_ = true;
    }
    return true;
}

bool Accepter::Close() {
}

}
